package com.aia.aia2.web.json;

import org.apache.log4j.Logger;

import com.aia.aia2.domain.Formdata;
import com.aia.aia2.domain.FormdataExt;
import com.aia.aia2.service.GroupService;
import com.cfh.util.JsonActionSupport;
import com.cfh.util.Tools;
import com.opensymphony.xwork2.ModelDriven;

@SuppressWarnings("serial")
public class GroupForm2Json extends JsonActionSupport implements ModelDriven<Formdata> {
	private static final Logger logger = Logger.getLogger(GroupForm2Json.class);
	private FormdataExt formdataExt = new FormdataExt();
	private GroupService groupService;
	private String rid;
	private String outputRid;
	private String from;

	public Formdata getModel() {
		return getFormdataExt();
	}

	public GroupService getGroupService() {
		return groupService;
	}

	public void setGroupService(GroupService groupService) {
		this.groupService = groupService;
	}

	@Override
	public void doExecute() {

		logger.debug("execute() Start");
		if ("form3".equals(from)) {
			groupService.updateGroupForm3(this);
		} else {
			// Validate it
			if (!Tools.hasText(rid)) {
				this.addActionError("rid参数为空！");
				return;
			}
			groupService.updateGroupForm2(this);
		}
		logger.debug("execute() End");
	}

	public FormdataExt getFormdataExt() {
		return formdataExt;
	}

	public void setFormdataExt(FormdataExt formdataExt) {
		this.formdataExt = formdataExt;
	}

	public String getRid() {
		return rid;
	}

	public void setRid(String rid) {
		this.rid = rid;
	}

	public String getOutputRid() {
		return outputRid;
	}

	public void setOutputRid(String outputRid) {
		this.outputRid = outputRid;
	}

	public String getFrom() {
		return from;
	}

	public void setFrom(String from) {
		this.from = from;
	}
}
